# coding=utf-8
# 全世界最帅的帅哥
import requests


def request_dispatcher(request, openid=None, url=None):
    method = request.method
    headers = dict(request.headers)
    headers["token"] = openid
    del headers["Authorization"]
    data = request.get_json() if request.is_json else request.form.to_dict()

    response = requests.request(method, url, headers=headers, json=data, params=request.args)
    return response

